<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //1s后显示111，完成后2s再显示222，完成后3s再显示333
        //回调地狱：回调函数里面再嵌套回调函数 无止境。。。
        function one(){
            setTimeout(function(){
                console.log(111)
                iterator.next()
            },1000)
        }
        function two(){
            setTimeout(function(){
                console.log(222)
                iterator.next()
            },2000)
        }
        function three(){
            setTimeout(function(){
                console.log(333)
                iterator.next()
            },3000)
        }
        //声明一个生成器
        function * gen(){
            yield one();
            yield two();
            yield  three();
        }
        let iterator = gen()
        iterator.next()
    </script>
</body>
</html>